package org.cloud.controller;


import org.cloud.entity.Dept;
import org.cloud.service.DeptClientService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/consumer/feign/dept")
public class ConsumerFeignController {

    @Resource
    private DeptClientService deptClientService;  // 注入 DeptClientService

    @GetMapping("/list") // 建立和 DeptClientService 的方法映射
    public List<Dept> ListDept() {
        return deptClientService.listDept();
    }

    @GetMapping("/get/{id}")
    public Dept getDept(@PathVariable("id") Integer id) {
        return deptClientService.getDept(id);
    }

    @PostMapping("/add")
    public boolean addDept(@RequestBody Dept dept) {
        return deptClientService.addDept(dept);
    }

    @GetMapping("/discovery/{serviceId}")
    public Object discovery(@PathVariable("serviceId") String serviceId) {
        return deptClientService.discovery(serviceId);
    }

    @GetMapping("/offline")
    public void offline() {
        deptClientService.offLine();
    }
}
